{layout "../Layout/layout.latte"}
{block tabs_content}
    {*{include "./tabs.latte"}*}
{/block}
{block custom}
    {include "../Public/custom.latte", title1=>"选择执行人", title2=>"选择验收人"}
{/block}
{block private_js}
    <script type="text/javascript" src="//g.alicdn.com/msui/sm/0.6.2/js/sm-city-picker.min.js" charset="utf-8"></script>
    <script type="text/javascript">
        $(function () {
            $("#bnt").click(function () {
                $.ajax({
                    type: "post",
                    url: $("#formArticle").attr("action"),
                    data: $("#formArticle").serialize(),
                    cache: false,
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                        $.toast(data.info);
                        if (data.status == "n") {
                            return false;
                        }else{
                            setTimeout(function () {
                                location.replace(data.url);
                            }, 1000);
                        }
                    }
                });
            });


            // window.ids = new Array();
            window.department = new Array();
            // ids.push(0);
            department.push("作为顶级部门");

            $.ajax({
                type: "post",
                url: "/ajaxDepartment",
                data: $("#formArticle").serialize(),
                cache: false,
                dataType: "json",
                async:false,
                success: function (data) {
                    console.log(data);
                    // ids = ids.concat(data.idsArr);
                    department = department.concat(data.departmentArr);
                }
            });

            $("#depSelector").picker({
                toolbarTemplate: '<header class="bar bar-nav">\
                <button class="button button-link pull-right close-picker">确定</button>\
                <h1 class="title">标题</h1>\
                </header>',
                cols: [
                    {
                        textAlign: 'left',
                        values: department
                    }
                ]
            });
        });
        function goback(){
            location.replace({url("mobileConsoles_company_departmentLists")})
        }
    </script>
    {include "../Public/customJs.latte"}
{/block}
{block private_css}
    <style>
        .item-title, input {
            font-size: 0.9rem !important;
        }

        .item-inner { height:3rem;}
    </style>
{/block}
{block content}
    <form id="formArticle" class="stdform mform" method="post" action="{url("mobileConsoles_company_addDepartment")}" onsubmit="return false">
        <div class="list-block">
            <ul>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-form-name"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">上级部门</div>
                            <div class="item-input">
                                <input type="text" id='depSelector' name="parentid" value="作为顶级部门"/>
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-form-name"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">部门名称</div>
                            <div class="item-input">
                                <input type="text" placeholder="部门名称" name="names">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-form-name"></i></div>
                        <div class="item-inner" style="height:unset;">
                            <div class="item-title label">部门描述</div>
                            <div class="item-input">
                                {*<input type="text" placeholder="简单介绍一下此部门" name="description" >*}
                                <textarea name="description"></textarea>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
    <div class="content-block">
        <div class="col-95">
            <div class="button button-big button-fill" id="bnt">提交</div>
        </div>
    </div>
    <div class="content-block">
        <div class="col-95">
            <a onclick="goback()" style="text-align: center;display: block;">返回</a>
        </div>
    </div>
{/block}